﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TRACv2.Domain.Entities;
using TRACv2.Common.Enumerations;

//Author: Morgan William Davis III
//Project: TRAC Ticket Manager v2
//Date: 21 Mar 2014

namespace TRACv2.Domain.Test
{
    [TestClass]
    [ExcludeFromCodeCoverage]
    public class TicketTest
    {
        private readonly Ticket _testTicket = new Ticket
        {
            ID = 1, Number = "testString", DateCreated = DateTime.Now,
            Contact = 1, Creator = 2, Issue = Issue.LaptopDisplay,
            Priority = Priority.Urgent, Status = Status.Hold,
            Note = "Someone needs some help."
        };

        #region [ Set Property Accesors ]

        #region [ ID Property ]

        [TestMethod]
        public void ID_ArgumentLessThanOne_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.ID = 0;
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        #endregion

        #region [ Number Property ]

        [TestMethod]
        public void Number_EmptyStringArgument_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.Number = "";
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        [TestMethod]
        public void Number_NullStringArgument_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.Number = null;
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        [TestMethod]
        public void Number_StringLengthOverFiftyArgument_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.Number = "thisisateststringthatshouldaccountforaminimumoffiftycharactersIdidntbothertocountbutthisshouldbemorethanenough.";
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        #endregion

        #region [ DateCreated Property ]

        [TestMethod]
        public void DateCreated_FutureDateArgument_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.DateCreated = DateTime.Now.AddDays(10);
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        #endregion

        #region [ Contact and Creator Properties ]

        [TestMethod]
        public void Creator_ArgumentLessThanOne_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.Creator = 0;
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        [TestMethod]
        public void Contact_ArgumentLessThanOne_ShouldNotValidate()
        {
            //Arrange
            var thisTicket = _testTicket;
            var validate = false;

            //Act
            try
            {
                thisTicket.Contact = 0;
            }
            catch (Exception)
            {
                validate = true;
            }

            //Assert
            Assert.IsTrue(validate);
        }

        #endregion

        #endregion

        #region [ Get Property Accesors ]

        [TestMethod]
        public void ID_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 1;
            var boolCheck = comparisonId == _testTicket.ID;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Number_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "testString";
            var boolCheck = comparisonString == _testTicket.Number;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void DateCreated_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            DateTime comparisonDate = DateTime.Now;
            var boolCheck = comparisonDate == _testTicket.DateCreated;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Contact_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 1;
            var boolCheck = comparisonId == _testTicket.Contact;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Creator_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const int comparisonId = 2;
            var boolCheck = comparisonId == _testTicket.Creator;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Issue_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const Issue comparisonIssue = Issue.LaptopDisplay;
            var boolCheck = comparisonIssue == _testTicket.Issue;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Priority_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const Priority comparisonPriority = Priority.Urgent;
            var boolCheck = comparisonPriority == _testTicket.Priority;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Status_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const Status comparisonStatus = Status.Hold;
            var boolCheck = comparisonStatus == _testTicket.Status;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        [TestMethod]
        public void Note_GetValue_ShouldReturnExpected()
        {
            //Arrange and Act
            const string comparisonString = "Someone needs some help.";
            var boolCheck = comparisonString == _testTicket.Note;

            //Assert
            Assert.IsTrue(boolCheck);
        }

        #endregion

    }
}
